﻿Public Partial Class distributors
    Inherits System.Web.UI.Page

    Dim selectedCountry As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub ddl_Countries_SelectedIndexChanged(sender As Object, e As EventArgs)
        selectedCountry = ddl_Countries.SelectedValue.ToString()
        rp_Distributors.DataBind()

    End Sub

    Protected Sub rp_Distributors_ItemDataBound(sender As Object, e As RepeaterItemEventArgs)
        If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
            'Dim name As Label = CType(rp_Distributors.FindControl("lbl_companyName"), Label)
            'Dim address As Label = CType(rp_Distributors.FindControl("lbl_address"), Label)
            'Dim city As Label = CType(rp_Distributors.FindControl("lbl_city"), Label)
            'Dim zip As Label = CType(rp_Distributors.FindControl("lbl_zip"), Label)
            Try
                Dim country As Label = CType(rp_Distributors.FindControl("lbl_country"), Label)
                If country.Text = "Rest of Europe" Then
                    country.Text = "Denmark"
                ElseIf country.Text = "Other" Then
                    country.Text = "USA"
                End If
            Catch ex As Exception

            End Try

            'Dim fulladdress As String = name.Text + " " + address.Text + " " + city.Text + " " + zip.Text + " " + country.Text
            Dim fulladdress As HiddenField = CType(e.Item.FindControl("gmapSrc"), HiddenField)
            Dim src As String = fulladdress.Value.ToString()
            src = src.Trim()
            If src.Contains("&") Then
                src = src.Replace("& ", "")
            End If
            If src.Contains("Rest of Europe") Then
                src = src.Replace("Rest of Europe", "Denmark")
            ElseIf src.Contains("Other") Then
                src = src.Replace("Other", "USA")
            End If
            src = src.Replace(" ", "+")
            gmap.Attributes("src") = "https://www.google.com/maps/embed/v1/place?key=AIzaSyDRO8Tg5nSbFyAa4DOnqgnN5XtywTb-ya0&q=" & src
            gmap.DataBind()
        End If

    End Sub
End Class